//
//  BaseTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/2/26.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "BaseTableViewCell.h"

@implementation BaseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)showBottomLineWithPaddingX:(CGFloat)padding color:(UIColor *)color
{
    if (!self.bottomLine.superview) {
        self.bottomLine = [UIView new];
        if (!color) {
            color = Color_RGB(238, 244, 252);
        }
        
        self.bottomLine.backgroundColor = color;
//        [self.bottomLine setFrame:CGRectMake(padding, self.frame.size.height-0.5, self.frame.size.width-padding*2, 0.5)];
        [self.contentView addSubview:self.bottomLine];
        [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(padding);
            make.right.mas_equalTo(-padding);
            make.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(0.5);
        }];
    }
}

- (void)hideBottomLine
{
    if (self.bottomLine.superview) {
        [self.bottomLine removeFromSuperview];
    }
}

- (void)showArrowWithImage:(UIImage *)image
{
    if (!self.arrowView.superview) {
        self.arrowView = [UIImageView new];
        if (!image) {
            image = [UIImage imageNamed:@"app_arrow_ic"];
        }
        
        self.arrowView.image = image;
        [self.arrowView setFrame:CGRectMake(self.frame.size.width - 12 - 15, (self.frame.size.height - 12)*0.5, 12, 12)];
        [self.contentView addSubview:self.arrowView];
    }
}

- (void)hideArrow
{
    if (self.arrowView.superview) {
        [self.arrowView removeFromSuperview];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    if (self.arrowView.superview) {
        [self.arrowView setFrame:CGRectMake(self.contentView.frame.size.width - 12 - 15, (self.contentView.frame.size.height - 12)*0.5, 12, 12)];
    }
}
@end
